using NJG;
using UnityEngine;

public class NPCDemo : MonoBehaviour
{
	public float damping = 6f;

	public float interval = 1f;

	public float walkSpeed = 3f;

	public LayerMask walkableLayers;

	private Vector3 mPos;

	private float mTime;

	private Transform mTrans;

	private void Awake()
	{
		mTrans = base.transform;
	}

	private void OnCollisionEnter(Collision col)
	{
		Move();
	}

	private void OnTriggerEnter(Collider col)
	{
		Move();
	}

	private void Update()
	{
		if (Time.time > mTime)
		{
			mTime = Time.time + interval;
			Move();
		}
		Vector3 vector = mPos - mTrans.position;
		if (vector != Vector3.zero)
		{
			Quaternion b = Quaternion.LookRotation(vector);
			mTrans.rotation = Quaternion.Slerp(mTrans.rotation, b, Time.deltaTime * damping);
		}
		mTrans.position = Vector3.Lerp(mTrans.position, mPos, Time.deltaTime * 0.06f);
	}

	private void Move()
	{
		if (NJGMapBase.instance != null)
		{
			mPos.x = Random.Range(NJGMapBase.instance.bounds.min.x, NJGMapBase.instance.bounds.max.x);
			mPos.y = mTrans.position.y;
			mPos.z = Random.Range(NJGMapBase.instance.bounds.min.y, NJGMapBase.instance.bounds.max.z);
		}
	}
}
